package com.example.common.context;

public class BaseContext {
    //ThreadLocal: 线程隔离特性，每个线程都可以存储自己独立的变量
    //线程隔离，每个线程都有自己的ThreadLocal变量，互不影响
    public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    public static Long getCurrentId() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }

}
